<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePositionDataTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('position_data', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('position_id')->nullable(); //显示位置ID
            $table->foreign('position_id')->references('id')
                ->on('show_position')->onDelete('cascade');
            $table->unsignedInteger('category_id')->nullable(); //对应栏目ID
            $table->foreign('category_id')->references('id')
                ->on('category')->onDelete('cascade');
            $table->unsignedInteger('article_id')->nullable(); //对应内容ID
            $table->foreign('article_id')->references('id')
                ->on('article')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('position_data');
    }
}
